package com.info.controller;


import com.entity.Info;
import com.entity.ResultMap;
import com.info.service.InfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
public class InfoController {

    @Autowired
    InfoService infoService;


    @RequestMapping(value = "/lendinfo" )
    public ResultMap<Info> lendinfo()
    {
        ResultMap<Info> resultMap = new ResultMap<>();
        //通过用户名拿到用户实体类
        List<Info> result = infoService.infos();
        //如果密码一致表示登录成功
        if (result != null ) {
            resultMap.setCode(200L);
            resultMap.setMessage("登录成功");
            resultMap.setResults(result);
        } else {
            resultMap.setCode(-1);
            resultMap.setMessage("登录失败");
        }
        return resultMap;
    }



}
